/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: SourceErrorCode.java   2020-10-10 13-47-31
 * Author: Evan
 */
package cn.datacare.orm.source;

import cn.datacare.orm.exception.ErrorCode;

import java.text.MessageFormat;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-10-10 13-47-31
 * @since V1.0
 */
public enum SourceErrorCode implements ErrorCode {
    ID_VALUE_ERROR("1014","无法设置复合主键:{0}"),
    ID_EXPECTED_ONE_ERROR("1004","UNQUE 方法需要传入主键的个数与数据库期望的主键个数不一致"),
    UNIQUE_EXCEPT_ERROR_1012("1012","unique查询，但数据库未找到结果集:参数是:{0}"),
    UNIQUE_EXCEPT_ERROR_1013("1013","unique查询，找到多条记录:参数是:{0}"),
    UNIQUE_EXCEPT_ERROR_1014("1014","unique查询:{0},但数据库未找到结果集:主键是:{1}"),
    UNIQUE_EXCEPT_ERROR_1015("1015","unique查询，但数据库未找到结果集"),
    UNIQUE_EXCEPT_ERROR_1016("1016","exsit{0},但数据库未找到结果集:主键是:{1}");
    /***
     * 错误
     */
    private String code;
    /***
     * 错误信息
     */
    private String message;

    SourceErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    /***
     * 错误代码
     * @return String String
     */
    @Override
    public String getCode() {
        return this.code;
    }

    /***
     * 异常消息
     * @return String String
     */
    @Override
    public String getMessage() {
        return this.message;
    }

    /***
     * 参数处理消息
     * @param params
     * @return String
     */
    @Override
    public String getMessage(Object... params) {
        return MessageFormat.format(this.message, params);
    }
}
